<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            background-color: #ffb5b5;
        }
        #box{
            background-color: #f2f2f2;
            width:500px;
            height:auto;
            margin: 0 auto;
            border-radius: 15px;
            overflow: hidden;
        }
        h3{
            text-align: center;
            margin-top: 20px;
        }
        #box>input{
            outline: none;
            width:300px;
            margin-left: 50px;
            border: 0;
            border-bottom: 3px dashed #fe7345 ;
            background-color: #f2f2f2;
            height: 30px;
            margin-bottom: 30px;
        }
        p{
            margin-left: 50px;
        }
        span{
            font-size: 17px;
            padding-top: 5px;
            color: rgba(73,74,75,.45);
            text-align: center;
            display: block;
        }
        b{
            float: right;
            margin-right: 30px;
        }
    </style>
</head>
<body>
    <div id="box">
        <h3>Today I need to </h3>
        <input v-model="msg" type="text" placeholder="Add new to do"> 
        <button @click="tijiao" :disabled="isDisabled">Submit</button>
        <div class="hezi">
            
            <p v-for="(item,index) in arr"> <input v-model="ischeck" type="checkbox">{{item}}
                <b @click="del">x</b>
            </p>
        </div>
        <span v-show="flag" >Congrat,you have no more tasks to do</span>
        <p v-show="ishid">{{arr.length}}</p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>  
    <script>
        new Vue({
            el:"#box",
                data:{
                    msg : "",
                    arr:[],
                    flag:true,
                    isDisabled:true,
                    ishid:false,
                    ischeck:false
                },
                methods:{
                    tijiao(){
                        // console.log(this.msg);
                        res=this.arr.push(this.msg);
                        this.msg ='';
                        console.log(this.arr.length);;
                        if(this.arr.length>0){
                            this.flag=false
                            this.ishid = true
                        }
                        else{
                            this.flag = true
                            this.ishid = false
                        }
                        
                    },
                    del(item,index){
                        this.arr.splice(index,1)
                    },
                    check(){

                    }
                },
                watch: {
                msg(newValue) {
                    if (newValue.length > 0 && newValue.trim().length !=0 ) {
                            this.isDisabled = false
                        }else{
                            this.isDisabled = true
                        }            
                    } 
                    }
        })
    </script>
</body>
</html>